<!--
/**************************************************
* @ ordercancelview.jsp
*
* Copyright   2005 Hitrust Technology Inc.
* Developed by SDC, Hitrust.
* All Rights Reserved.
*
* Modify History:
*  v1.00, 2006/03/15, owen
*   1) first release
*  v1.10, 2006/03/17, Jenny Li
*	1)修改订货单位和送货地址的联动查询 
*   2)修改明细状态为动态查询
*   3)更正分页查询不到结果的问题
*  
/**************************************************
-->
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ include file="../../../common.jsp" %>
<%@ taglib uri="/page.util.gs.hitrust.com/taglibs/page" prefix="page"%>
<%@page import="system.LoginContext"%>
<%@page import="framework.core.SrvContext"%>
<html>
<head>
<title>取消审购单</title>
<META http-equiv=Content-Type content="text/html; charset=UTF-8">
<LINK href="<%=root%>/css/caigouxitong.css" type=text/css rel=stylesheet>
<SCRIPT language="JavaScript" src="<%=root%>/js/common.js"></SCRIPT>
<SCRIPT language=javascript src="<%=root%>/framework/js/datePicker/WdatePicker.js"></SCRIPT>
<%
	ArrayList wareList = (ArrayList)request.getAttribute("orderdept");
	ResultProcess tOrder = (ResultProcess)request.getAttribute("order");
	ArrayList tList = new ArrayList();
	String tReQuery = (String)request.getAttribute("requery");

%>
<script>

	var counter;
	function process(val){
		if(val == 'Q' || val == 'Qre'){
				  if (val == 'Qre') {
					<%
					    if(tReQuery!=null && tReQuery.equals("true")){
					%>
						ordercancelform.action = "<%= response.encodeURL(request.getContextPath() + "/A100602.do") %>";
			    		ordercancelform.submit();
			    	<%}%>
		    	} else if (val == 'Q') {
						var tStr = "";		
						var tEnd = "";				
						if(!isEmpty(ordercancelform.orderCreateDateStr.value)){
							tStr = ordercancelform.orderCreateDateStr.value.substr(0,4) + ordercancelform.orderCreateDateStr.value.substr(5,2) + ordercancelform.orderCreateDateStr.value.substr(8,2);
						}
						if(!isEmpty(ordercancelform.orderCreateDateEnd.value)){
							tEnd = ordercancelform.orderCreateDateEnd.value.substr(0,4) + ordercancelform.orderCreateDateEnd.value.substr(5,2) + ordercancelform.orderCreateDateEnd.value.substr(8,2);						
						}
						if(parseInt(tStr) > parseInt(tEnd)){
								alert("订单创建周期的开始日期不能大于截止日期！");
								return false;
						}		
						
						ordercancelform.action = "<%= response.encodeURL(request.getContextPath() + "/A100602.do") %>";
			    		ordercancelform.submit();
		    	}
    	
		}else if(val == 'C'){

			ordercancelform.orderId.value ="";
			ordercancelform.orderStatus.value="00";			
			ordercancelform.orderDeptId.selectedIndex=0;
			ordercancelform.concentricityId.value = "";
			ordercancelform.manufInfo.value = "";
			ordercancelform.orderCreateDateStr.value = "";						
			ordercancelform.orderCreateDateEnd.value = "";
            ordercancelform.drawingpiececode.value = "";  									
			return;
		}else if(val == 'T'){
			  var orderId;					
				
		
		if(!isCheckBoxselected(document.pager,document.pager.orderIds)){
				alert("请选择一个取消的申购单。");
				return false;				
			}else{		
				if(confirm("是否确定取消所选申购单信息？")){					
					if(document.pager.orderIds.length > 1){
						for(i=0; i<document.pager.orderIds.length;i++){
							if(document.pager.orderIds[i].checked){
								document.frmtijiao.orderIds[i].checked = true;
								document.frmtijiao.orderIds[i].value=document.pager.orderIds[i].value;
							}
						}
					}else if(document.pager.orderIds.checked){
							document.frmtijiao.orderIds.checked = true;
							document.frmtijiao.orderIds.value=document.pager.orderIds.value;
					}
					document.frmtijiao.orderId.value=document.ordercancelform.orderId.value;		
				    document.frmtijiao.orderStatus.value=document.ordercancelform.orderStatus.value;		
				    document.frmtijiao.orderDeptId.value=document.ordercancelform.orderDeptId.value;		
				    document.frmtijiao.concentricityId.value=document.ordercancelform.concentricityId.value;		
				    document.frmtijiao.manufInfo.value=document.ordercancelform.manufInfo.value;		
				    document.frmtijiao.orderCreateDateStr.value=document.ordercancelform.orderCreateDateStr.value;		
				    document.frmtijiao.orderCreateDateEnd.value=document.ordercancelform.orderCreateDateEnd.value;		
				    document.frmtijiao.submit();
				}else{
					return false;
				}
			}
		}
		else if(val == 'P'){
			if(confirm("是否确定打印？")){
				print_bill();//ordermanufacturevdetail.action = "<%=root%>/A100305.do";			
			}else{
				return false;
			}
		}
	}
</script>

</head>

<body BGCOLOR="#f2f2f2"	text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onload="process('Qre')">
<form name=ordercancelform method="get" >
<p><br></p>
<table width="98%" border="0" cellspacing="0" cellpadding="0" align="center">
	<tr>
		<td height="20">
			<table width="100%" border="0" cellspacing="0" cellpadding="1">
				<tr height="20">
					<td height="30" width="758" class="mtxt_black">申购单取消
					</td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td class="bg_line" height="2"></td>
	</tr>
</table>
<br>
<table width="98%" border="0" cellspacing="0" cellpadding="0" align="center">
	<tr> 
		<td> 
			<table class=bg_table id=tableId	cellspacing=1 cellpadding=0 style="padding-left:5;padding-right:5" width=100% align=center border=0>
				<TR height=20>
					<TD class="bg_column" align=center width="15%">申购单编号</TD>
					<TD align=left class="bg_row_odd" width="35%">
					<input type="text" name="orderId" value="<%=request.getParameter("orderId")==null? "":request.getParameter("orderId") %>" maxlength="20"></TD>					
					<TD class="bg_column" align=center width="15%">明细状态</TD>
					<TD align=left class="bg_row_odd" width="35%">
						<select name="orderStatus">					
						<option value="00">---全部---</option>
						<%
							String tOrderDetailStatus = (String)request.getAttribute("orderStatus");
							String[][] tDetailStatus = GSBaseManager.getAllOrderDetailStatusForCancle();
							if(tDetailStatus != null && tDetailStatus.length > 0 ){
								for(int i=0; i<tDetailStatus.length; i++){
									String[] temp = tDetailStatus[i];
									if(tOrderDetailStatus != null && tOrderDetailStatus.equals(temp[0])){
						%>
										<option value="<%=temp[0]%>" selected>
										<%=temp[1]%></option>
						<%				    
									}else{
						%>
										<option value="<%=temp[0]%>" >
										<%=temp[1]%></option>
						<%			
									}
								}
							}
						%>
						</select>
					</TD>	
				</TR>
				<TR height=20>							
					<TD class="bg_column" align=center>订货单位</TD>
					<TD left=right class="bg_row_odd">
						<select name="orderDeptId">                   
                        <option value="<%=LoginContext.get(new SrvContext(request,response)).getLoginWarehouseCode() %>">---全部---</option>
                        <%
                            String tOrderDept = request.getParameter("orderDeptId")==null?"":request.getParameter("orderDeptId");
                            if(wareList != null && wareList.size() > 0 ){
                                    for(int i=0; i<wareList.size(); i++){
                                        GSWareHouseBean tmp=(GSWareHouseBean)wareList.get(i);
                                        if(tmp != null && tOrderDept.equals(tmp.getCode())){
                            %>
                                            <option value="<%=tmp.getCode()%>" selected>
                                            <%=tmp.getName()%></option>
                            <%                  
                                        }else{
                            %>
                                            <option value="<%=tmp.getCode()%>"><%=tmp.getName()%></option>
                            <%          
                                        }
                                    }
                                }
                        %>
                        </select>
					</TD>
                    <td class="bg_column" align=center>图件号</td>
                    <td align=left class="bg_row_odd" >
                    <input type="text" name="drawingpiececode" value="<%=request.getParameter("drawingpiececode")==null? "":request.getParameter("drawingpiececode") %>">
                    </td> 						
				</TR>				
				<TR height=20>
					<TD class="bg_column" align=center>集中编码</TD>
					<TD align=left class="bg_row_odd" colspan="3">
					<input type="text" name="concentricityId" maxlength="20" value="<%=request.getParameter("concentricityId")==null?"":request.getParameter("concentricityId")%>">
					</TD>
				</TR>									
				<TR height=20>
					<TD class="bg_column" align=center>产品信息</TD>
					<TD align=left class="bg_row_odd" colspan="3">
					<input type="text" name="manufInfo" maxlength="200" value="<%=request.getParameter("manufInfo")==null?"":request.getParameter("manufInfo")%>">（<FONT color="#ff0033">对产品名称、型号、规格、品牌、生产厂商、附加属性等关键字的模糊查询</FONT>）&nbsp;
					</TD>
				</TR>
                <%
                SimpleDateFormat bartDateFormat = new SimpleDateFormat("yyyy-MM-dd");
                Date d = new Date();
                String strNow = String.valueOf(bartDateFormat.format(d));
                long l=(long)259200*(long)10000;
                Date d2 = new Date(System.currentTimeMillis()-l);
                String strMothAgo = String.valueOf(bartDateFormat.format(d2));
                
                %> 							
				<TR height=20>	
					<TD class="bg_column" align=center>创建时间</TD>
					<TD align=left class="bg_row_odd" colspan="3">
					<%=framework.custom.UIManager.generateDateInput("orderCreateDateStr",
							request.getParameter("orderCreateDateStr")==null?strMothAgo:request.getParameter("orderCreateDateStr"))%>
					
					至
					<%=framework.custom.UIManager.generateDateInput("orderCreateDateEnd",
							request.getParameter("orderCreateDateEnd")==null?strNow:request.getParameter("orderCreateDateEnd"))%>
					
					
					</TD>
				</TR>
                        <%
                        if(tOrder != null) {
                            int totalRecords = 0;
                            if(request.getAttribute("totalRecords")!=null){
                                totalRecords=Integer.parseInt((String)request.getAttribute("totalRecords"));
                            }
                            int defaultPageSize =10;
                            if(request.getAttribute("pageSize")!=null){
                                defaultPageSize=Integer.parseInt((String)request.getAttribute("pageSize"));
                            }
                            totalRecords=tOrder.getRecordsSize();
                        %>          
                        <page:pager total='<%=totalRecords%>' defaultPageSize='<%=defaultPageSize%>'>
                        <%tList = tOrder.getDisplayRecords(index.intValue(),pageSize.intValue()); %>
                        </page:pager>
                        <%} %>
			</table>
		</td>
	</tr>
</table>
</form>
    <p align="center">  
         <input type="button" class="kuang" value="查询" onclick="process('Q')">&nbsp;
		<input type="button" class="kuang" value="清空" onclick="process('C')"/>&nbsp;		
    </p>

<%

    if (tReQuery!=null && tReQuery.equals("true")) {
%>    
	<font size="2">数据查询中......</font>
<%
	}
	if(tOrder != null){
%>
	<center>
    
    <table width="98%" border="0" cellspacing="0" cellpadding="0" align="center">
		<tr>
			<td>
            <form name='pager' method="post">
            <input type="hidden" name="orderId" >
            <input type="hidden" name="orderCategory">            
            <input type="hidden" name="orderDept" >            
            	<table class=bg_table id=tableId	cellspacing=1 cellpadding=2 width=100% align=center border=0>
                    <tbody> 

                    <tr class="bg_column" height=20> 
                    	<td></td>
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">申购单编号</div>
						</td>                    
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">申购单明细编号</div>
						</td>                    			
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">明细状态</div>
						</td>												
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">集中编码</div>
						</td>
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">产品名称</div>
						</td>
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">规格</div>
						</td>
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">型号</div>
						</td>																																				
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">品牌</div>
						</td>
						<td class=top align=middle> 
                        <div align="center" class="txt_content">质保期</div>
						</td>
                        <td class=top align=center> 
                        <div align="center" class="txt_content">图件号</div>
                        </td>
						<td class=top align=middle> 
                        <div align="center" class="txt_content">价格（元）</div>
						</td>											
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">订货数量</div>
						</td>																									
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">创建时间</div>
						</td>										
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">订货单位</div>
						</td>		
						<td class=top align=middle> 
                        <div align="center" class="txt_content">供应商</div>
						</td>	
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">结算模式</div>
                        </td>																																		
                        <td class=top align=middle> 
                        <div align="center" class="txt_content">详细信息</div>
						</td>																																				
					</tr>
					<%
						if(tList != null && tList.size() > 0){
						for(int i=0; i<tList.size(); i++){
							GSOrderAnaDetailBean detail=(GSOrderAnaDetailBean)tList.get(i);
							String tTempStr="";
							if(i%2==0){
								tTempStr="class=\"bg_row_odd\"";
							}else {
								tTempStr="class=\"bg_row_even\"";
							}
					%>
							<tr <%=tTempStr%> height=20>
								<td class=top align=middle> 
									<div align="center" class="txt_content">
									 <input type=checkbox name=orderIds value="<%=detail.getGs_order_detail_id()%>" >								    
									 </div>
								</td>							
								<td class=top align=middle> 								
									<div align="center" class="txt_content">
									<%=detail.getGs_order_tempid()%>
									</div>
								</td>	
								<td class=top align=middle> 								
									<div align="center" class="txt_content">
									<%=detail.getGs_order_detail_id()%>
									</div>
								</td>									
								<td class=top align=middle> 								
									<div align="center" class="txt_content">
									<%=GSBaseManager.getOrderDetailStatusName(detail.getGs_order_detail_status())%>
									</div>
								</td>	
								<td class=top align=middle> 
									<div align="center" class="txt_content">
									<%=detail.getGs_concentricity_id()%>
									</div>
								</td>														
								<td class=top align=middle > 								
									<div align="center" class="txt_content">
									<a href="<%= response.encodeURL(request.getContextPath() + "/A100306.do") %>?concentricityId=<%=detail.getGs_concentricity_id()%>" target="contentForm"><%=detail.getName_product()%></a>
									</div>
								</td>	
								<td class=top align=middle> 
									<div align="center" class="txt_content">
									<%=detail.getSpec()%>
									</div>
								</td>				
								<td class=top align=middle> 
									<div align="center" class="txt_content">
									<%=detail.getModel()%>
									</div>
								</td>													
								<td class=top align=middle> 
									<div align="center" class="txt_content">
									<%=detail.getProduct_brand()%>
									</div>
								</td>
								<td class=top align=middle> 
                                    <div align="center" class="txt_content">
                                    <%=detail.getQuality_assure_period()%>
                                   </div>
						        </td>
                                <td class=top align=middle> 
                                    <div align="center" class="txt_content">
                                    <%=detail.getDrawing_piece_code()%>
                                   </div>
                                </td>
						        <td class=top align=middle> 
                                   <div align="center" class="txt_content">
                                    <%=StringUtils.formatEDouble(detail.getGs_goods_unitprice(),4)%>
                                   </div>
						        </td>
								<td class=top align=middle> 
									<div align="center" class="txt_content">
									<%=StringUtils.formatEDouble(detail.getGs_order_count(),2)%><%=detail.getProduct_unit()%>
									</div>
								</td>								
								<td class=top align=middle> 
									<div align="center" class="txt_content">
									<%=detail.getGs_order_create_date()%>
									</div>
								</td>								
								<td class=top align=middle> 
									<div align="center" class="txt_content">
									<%=detail.getName_warehouse()%>
									</div>
								</td>
								<td class=top align=middle> 
									<div align="center" class="txt_content">
									<a href="<%=response.encodeURL(root+"/A400108.do")%>?providerId=<%=detail.getCode()%>" target=_blank>
									<%=detail.getName()%>
									</a>
									</div>
								</td>	
                                <td class=top align=middle> 
                                    <div align="center" class="txt_content">
                                    <%=DefineDic.getBalanceMode(detail.getGs_balance_mode())%>
                                    </div>
                                </td>																											
								<td class=top align=middle> 
									<div align="center" class="txt_content">
									<a href="<%= response.encodeURL(request.getContextPath() + "/A100506.do") %>?orderId=<%=detail.getGs_order_tempid()%>&orderDetailId=<%=detail.getGs_order_detail_id()%>" target="contentForm">详细</a>
									</div>
								</td>																																								
							</tr> 
					<%
						}
					%>
						  <tr class="bg_column" height=20>
						    <td width="960" height="16" colspan="18" align="right">
									<!--导航条-->
						    		<page:navigator type='text' queryForm ='ordercancelform'/>
						    </td>
						  </tr>					
				    <%
						}else{
					%>
							
                            <tr class="bg_column" height=20>
                            <td width="960" height="16" colspan="18" align="center">
                               <font color="red">没有符合条件的申购单信息,请重新输入查询条件</font>
                            </td>
                            </tr>
					<%
						}
					%>
					</tbody>
				</table>
				</form>					  
			</td>
		</tr>
	</table>
	</center>
	
	
    <form action="<%=response.encodeURL(root+"/A100604.do")%>" name="frmtijiao" method="post">	
		<div style='display:none'>
		<%
			if(tList != null){
				for(int i=0; i<tList.size(); i++){
		%>
			<input type="checkbox" name="orderIds">
		<%		
				}
			}
		%>
		<input type="hidden" name="orderId">
		<input type="hidden" name="orderStatus">
		<input type="hidden" name="orderDeptId">
		<input type="hidden" name="deliverGoodsAddrId">
		<input type="hidden" name="concentricityId">
		<input type="hidden" name="manufInfo">
		<input type="hidden" name="orderCreateDateStr">
		<input type="hidden" name="orderCreateDateEnd">
		</div>	
     </form>	
		<p align="center">  
	<%
		if(tList!= null && tList.size() > 0){
	%>
    <input type="button" class="kuang" value="取消采购" onclick="process('T')">
    <!--
    <input type="image" src="images/button/dayin.gif" width="86" height="24" class="box" onclick="process('P')"/>&nbsp;
	 -->
	<%
		}
	%>
    </p>
<%		
	}
%>
</html>